<script type="text/javascript">
function saveMemo(oid){
	var amemo=document.getElementById('amemo').value;
	//var ship=document.getElementById('ship').value;
	//var surtax=document.getElementById('surtax').value;
	location.href="page/saveMemo.php?oid="+oid+"&amemo="+amemo;
	//+"&surtax="+surtax+"&ship="+ship
	location.href="<?=base_url('order/saveMemo')?>?oid="+oid+"&amemo="+amemo;
}
</script>
<div class="content_table_detail">
<table cellspacing="0" cellpadding="0" border="0" style="border-collapse: collapse;width: 970px;background: url('images/title_03.gif') repeat-x scroll 0% 0% transparent;" >
				<thead>
					<tr>
						<th style="text-align: left;background: url('images/title_03.gif') repeat-x scroll 0% 0% transparent;height: 24px;">
						<?php 
						
						?>
						
						</th>
						
					</tr>
				</thead>
				</table>
				<br>
			<table cellspacing="0" cellpadding="0" border="0" >
				<colgroup>
					<col width="100px">
					<col width="700px">
				</colgroup>
				<tbody>
					<tr>
						<th>Mã đơn hàng</th>
						<td>
							<div class="contBox"><?=$order_detail[0]['code_order']?></div>
						</td>
					</tr>
					<tr>
						<th>Tên khách hàng</th>
						<td>
							<div class="contBox"><?=$order_detail[0]['aname']?></div>
						</td>
					</tr>
					<tr>
						<th>Email</th>
						<td>
							<div class="contBox"><?=$order_detail[0]['email']?></div>
						</td>
					</tr>
					<tr>
						<th>Địa chỉ</th>
						<td>
							<div class="contBox"><?=$order_detail[0]['address']?></div>
						</td>
					</tr>
					
					
					<tr>
						<th>Quận/Huyện</th>
						<td>
							<div class="contBox"><?=$order_detail[0]['ndistrict']?></div>
						</td>
					</tr>
					<tr>
						<th>Tỉnh/Thành phố</th>
						<td>
							<div class="contBox"><?=$order_detail[0]['ncity']?></div>
						</td>
					</tr>
					<tr>
						<th>Điện thoại</th>
						<td>
							<div class="contBox"><?=$order_detail[0]['phone']?></div>
						</td>
					</tr>
					
					<tr>
						<th>Ngày tạo</th>
						<td>
							<div class="contBox"><?=$order_detail[0]['date']?></div>
						</td>
					</tr>
					<tr>
						<th>Loại thanh toán</th>
						<td>
							<div class="contBox">
							<?php if($order_detail[0]['payment']==1) echo "Giao hàng thu tiền tận nơi";
								  if($order_detail[0]['payment']==2) echo "Mua hàng thanh toán tại văn phòng";
								  if($order_detail[0]['payment']==3) echo "Thanh toán bằng thẻ ATM hoặc chuyển khoản";
							?>
							</div>
						</td>
					</tr>
					<tr>
						<th>Lời nhắn khách hàng</th>
						<td>
							<div class="contBox">
							<div style="height:80px; border:1px; overflow:auto;"><?=$order_detail[0]['memo']?></div>
						
						
						</div>
						</td>
					</tr>
					<tr>
						<th colspan="2">Chi tiết đơn hàng</th>
						
					</tr>
				
					<tr>
						<td colspan="2">
						<table>
						
						<thead>
					<tr>
						<th style="width: 20px;">STT</th>
						<th style="width: 150px;">Tên Deal</th>
						<th style="width: 25px;">Số Lượng</th>
						<th style="width: 50px;">Giá Tiền</th>
						<th style="width: 20px;"></th>
						
					</tr>
				</thead>
								<tbody>
					
					<?php 
					$total=0;
					$so=1;
					foreach ($order_detail as $value){?>
					
								<tr>
									<td style="width: 20px;"><?=$so?></td>
									
									<td><a href="../deal_detail?did=<?=$value['id_deal']?>" target="_blank"><?php  echo $value['name'];?></a></td>
									<td><?php  echo $value['quantity'];?></td>
									<td><?php  echo number_format($value['price']);?></td>
									<td style="text-align: left;"><?php ?></td>
									
								</tr>
								
							
					
					<?php 
						
						$so++;
						$total+=($value['price']*$value['quantity']);
					}
					?>
					</tbody>
					
					</table>
						</td>
					</tr>
					 <tr>
							<td colspan="2" >
							<table style="width: 250px;float: right;">
							<tr>
									<th style="width: 100px"> Tổng tiền</th>
									<td style="width: ;text-align: right;" id="total1"><?=number_format($total)?> </td>
							</tr>
							</table>
								
							</td>
					</tr>	
					 <tr>
						<td colspan="2">
							<table style="width: 100%;">
							
							<tr>
							<th rowspan="4" style="width: 100px;">Ghi chú của admin</th>
							<td rowspan="4">
									<textarea rows="4" cols="20" id="amemo" style="width:100%;"><?=$order_detail[0]['amemo']?></textarea>
							</td>
							</tr>
							<tr>
							<!--<th style="width: 100px;">Total</th>		
							<td style="width: 120px;text-align: right;" id="total"><?=number_format($total1)?> VND</td>

							</tr>
							
							 <tr>
							<th style="width: 100px;"><?=$l_ship?></th>
							<td style="width: 120px;"><input id="ship"  value="<?=number_format($order[10])?>" onchange="changeShip()" onkeypress="changeShip()" onkeyup="changeShip()"  style="width:80px;text-align: right;" > VND</td>
							</tr>
							
							<tr>
							<th style="width: 100px;">Surtax</th>
							<td style="width: 120px"><input id="surtax"  value="<?=number_format($order[13])?>" <?php //if($order[8]!=0) echo 'readonly="readonly"'; else  if($order[9]!=1)  echo 'readonly="readonly"';?> onchange="changeSurtax()" onkeypress="changeSurtax()" onkeyup="changeSurtax()"  style="width:80px;text-align: right;" > VND</td>
							</tr> -->
							
							</table>
							
						</td>
						
					</tr>
					
				</tbody>
				<tfoot>
					<tr>
						<td colspan="2">
						
							<div class="divBtn" style="width:70px; float:right;"  onclick="saveMemo('<?=$oid?>')">Lưu ghi chú</div>
						
							<?php if($order_detail[0]['ostatus']==0){?>
								<div class="divBtn" style="width:60px; float:right; margin:0px 5px;" onclick="var hoi=confirm('Bạn có chắc không?');if(hoi==true){location.href='<?=base_url('order/changtype?oid='.$oid.'&type=1')?>'}">Xác nhận</div>
								<div class="divBtn" style="width:60px; float:right; margin:0px 5px;" onclick="var hoi=confirm('Bạn có chắc không?');if(hoi==true){location.href='<?=base_url('order/changtype?oid='.$oid.'&type=-1')?>'}">Hủy Order</div>
							<?php }?>
							<?php if($order_detail[0]['ostatus']==1){?>
								<div class="divBtn" style="width:60px; float:right; margin:0px 5px;" onclick="var hoi=confirm('Bạn có chắc không?');if(hoi==true){location.href='<?=base_url('order/changtype?oid='.$oid.'&type=2')?>'}">Vận chuyển</div>
								<div class="divBtn" style="width:60px; float:right; margin:0px 5px;" onclick="var hoi=confirm('Bạn có chắc không?');if(hoi==true){location.href='<?=base_url('order/changtype?oid='.$oid.'&type=-1')?>'}">Hủy Order</div>
							<?php }?>
							<?php if($order_detail[0]['ostatus']==2){?>
								<div class="divBtn" style="width:60px; float:right; margin:0px 5px;" onclick="var hoi=confirm('Bạn có chắc không?');if(hoi==true){location.href='<?=base_url('order/changtype?oid='.$oid.'&type=3')?>'}">Thanh toán</div>
								<div class="divBtn" style="width:60px; float:right; margin:0px 5px;" onclick="var hoi=confirm('Bạn có chắc không?');if(hoi==true){location.href='<?=base_url('order/changtype?oid='.$oid.'&type=-1')?>'}">Hủy Order</div>
							<?php }?>
							
							<?php if($order_detail[0]['ostatus']==3){?>
								Đã thanh toán
							<?php }?>
							
							<?php if($order_detail[0]['ostatus']==-1){?>
								Đã hủy
								<div class="divBtn" style="width:60px; float:right; margin:0px 5px;" onclick="var hoi=confirm('Bạn có chắc không?');if(hoi==true){location.href='<?=base_url('order/changtype?oid='.$oid.'&type=0')?>'}">Khôi Phục</div>
							<?php }?>
						</td>
					</tr>
				</tfoot>
			</table>


			</div>
	